﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class book : items
    {
        public double PredC;// цена предложения        
        public string Author;
        public override string SaveToCSV()
        {
            string str;
            str = "Book" + ';' + id.ToString() + ';' + PredC.ToString() + ';' + Author + ';' + CopyCount.ToString() + ';' + Cost.ToString();
            return str;
        }
        public override void LoadFromCSV(string[] p)
        {
            id = Int32.Parse(p[1]);
            PredC = Double.Parse(p[2]);
            Author = p[3];
            CopyCount = Int32.Parse(p[4]);
            Cost = Double.Parse(p[5]);
        }

        public override string SaveToXML()
        {
            string str;
            str = "<item class=" + '"' + "Book" + '"' + "><Id>" + id.ToString() + "</Id><PredC>" + PredC.ToString() + "</PredC><Author>" + Author + "</Author><CopyCount>" + CopyCount.ToString() + "</CopyCount><Cost>" + Cost.ToString() + "</Cost></item>";
            return str;
        }
        public override void LoadFromXML(string[] p)
        {
            id = Int32.Parse(p[6]);
            PredC = Double.Parse(p[10]);
            Author = p[14];
            CopyCount = Int32.Parse(p[18]);
            Cost = Double.Parse(p[22]);
        }
        public override string SaveToJSON()
        {
            string str;
            str = @"{""Book:""{ ""id"":" + this.id + @",""PredC"":" + this.PredC + @",""Author"":""" + Author + @""",""CopyCount"":" + this.CopyCount + @",""Cost"":" + this.Cost + @"}}";
            return str;
        }
        public override void LoadFromJSON(string[] p)
        {
            id = Int32.Parse(p[6]);
            PredC = Double.Parse(p[10]);
            Author = p[16];
            CopyCount = Int32.Parse(p[20]);
            Cost = Double.Parse(p[24]);
        }
        public override string SaveToYAML()
        {
            string str;
            str = @"Book:{id:" + this.id + @",PredC:" + this.PredC + @",Author:" + Author + @",CopyCount:" + this.CopyCount + @",Cost:" + this.Cost + @"}";
            return str;
        }
        public override void LoadFromYAML(string[] p)
        {
            id = Int32.Parse(p[3]);
            PredC = Double.Parse(p[5]);
            Author = p[7];
            CopyCount = Int32.Parse(p[9]);
            Cost = Double.Parse(p[11]);
        }
        public override string SaveToDB()
        {
            string str;
            str = @"Book:{id:" + this.id + @",PredC:" + this.PredC + @",Author:" + Author + @",CopyCount:" + this.CopyCount + @",Cost:" + this.Cost + @"}";
            return str;
        }
        public override void LoadFromDB(string[] p)
        {
            id = Int32.Parse(p[3]);
            PredC = Double.Parse(p[5]);
            Author = p[7];
            CopyCount = Int32.Parse(p[9]);
            Cost = Double.Parse(p[11]);
        }
    }

}
